<?php
/* 
* @Author: LDF QQ 47121862
* @Date:   2014-05-13 18:06:02
* @Last Modified by:   LDF QQ 47121862
* @Last Modified time: 2014-05-14 10:00:20
*/
Class GoodsTypeControl extends AuthControl{
	private $db;
	function __auto(){
		$this->db = K('GoodsType');
	}
	// 类型列表
	function index(){
		$this->data = $this->db->all();
		$this->display();
	}
	//添加商品类型
	function add(){
		if(IS_POST){
			if($this->db->addGoodsType($_POST)){
				$this->success('添加商品类型成功');
			}else{	
				$this->error($this->db->error);
			}
		}else{
			$this->display();
		}
	}
	//修改商品类型
	function edit(){
		if(IS_POST){
			if($this->db->saveGoodsType($_POST)){
				$this->success('修改商品成功',U('index'));
			}else{
				$this->error($this->db->error);
			}
		}else{
			$id=Q('id');
			$this->data=$this->db->find($id);
			$this->display();
		}
	}
	//删除商品类型
	function del(){
		if($this->db->delGoodsType(Q('get.id'))){
			$this->success('删除商品成功',U('index'));
		}else{
			$this->error($this->db->error);
		}
	}
	//更新缓存
	function updateCache(){
		if($this->db->updateCache()){
			$this->success('更新缓存成功');
			//ajax更新缓存
			// $this->ajax(array('state'=>1,'message'=>'缓存更新成功'));
		}else{
			$this->error($this->db->error);
		}
	}
}
